# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=rime-loengfan
pkgver=0.0.0.20220303
_commit=987ac95b02f957e8764a2f45222a4006c188ed50
pkgrel=1
pkgdesc="Cantonese version of Liang Fen input method"
arch=('loong64' 'x86_64')
url="https://github.com/CanCLID/rime-loengfan"
license=('CCPL:by')
depends=('rime-cangjie')
makedepends=('librime' 'rime-prelude' 'rime-essay')
source=("https://github.com/CanCLID/rime-loengfan/archive/$_commit/rime-loengfan-$_commit.tar.gz")
sha512sums=('404b570d008f3a672f723c06f770fd453a14da65b50df33a40b0d25f8ee751308534b17d83202c30da82cfb0936cf6de96db2659388a50dcd8a28ca4d7fb3038')

prepare() {
  cd $pkgname-$_commit
  # Link essentials
  for _f in $(pacman -Qql rime-prelude rime-essay | grep -v "/$"); do ln -sf $_f; done
}

build(){
  cd $pkgname-$_commit
  for _s in $(ls *.schema.yaml); do rime_deployer --compile $_s; done
}

package() {
  cd $pkgname-$_commit
  find . -type l -delete
  rm build/*.txt
  install -Dm644 *.yaml -t "$pkgdir"/usr/share/rime-data/
  install -Dm644 build/* -t "$pkgdir"/usr/share/rime-data/build/
}
